--------------------------------------------------------------------------
--[[ 全局 ]]
--------------------------------------------------------------------------

-- 梧桐的模版让我有点不适应,不愿意大改框架,所以就硬着头皮上了,不过料理代码我还是得改改

-- 下行代码只代表查值时自动查global,增加global的变量或者修改global的变量时还是需要带"GLOBAL."
GLOBAL.setmetatable(env, { __index = function(t, k) return GLOBAL.rawget(GLOBAL, k) end })
GLOBAL.PASTORALAPI = env
local _G = GLOBAL
local IsServer = TheNet:GetIsServer() or TheNet:IsDedicated()

-- 田园牧歌种子包可以开出的种子以及权重
TUNING.PASTORAL_SEEDPACKET = {
    pastoral_soybean_seeds = 1,
    bamboo_shoot_seeds = 1,
}

PrefabFiles = {
    "items_pastoral",           -- 模组物品
    "buffs_pastoral",           -- 模组buff
    "fx_pastoral",              -- 模组特效
    "fruit_essence",            -- 丹木提取液
    "eggplant_avoiding_needle", -- 避茄针
    "foods_pastoral",           -- 模组料理
    "pastoral_seedpacket",      -- 种子包
}

local TF_PrefabFiles = {
    "pastoral_tf_seedpacket",   -- 食趣种子包
    "pastoral_tf_spices",       -- 食趣调味粉
    "pastoral_tf_spices_foods", -- 食趣调味料理
    "pastoral_tf_buffs",        -- 食趣buff
}

local XZKB_PrefabFiles = {
    "vagteouqivwx_yus_wmquwe_xqmxrwyiy", -- 草莓酱(代码名是因为对方mod加密混淆导致的,烤草莓也混淆了,不过为了保持统一我没用混淆后的代码名,问题不大)
}

local DAOGUI_PrefabFiles = {
    "pastoral_daogui_ganoderma", -- 灵芝和灵芝种子
    "pastoral_daogui_ginseng",   -- 人参和人参种子
}

Assets = {
    Asset("ANIM", "anim/farm_plant_piggymimosa.zip"),      -- 晗猪草作物动画
    Asset("ANIM", "anim/piggymimosa.zip"),                 -- 晗猪草果实动画
    Asset("ANIM", "anim/farm_plant_pastoral_soybean.zip"), -- 大豆作物动画
    Asset("ANIM", "anim/pastoral_soybean.zip"),            -- 大豆果实动画
    Asset("ANIM", "anim/farm_plant_bamboo_shoot.zip"),     -- 竹笋作物动画
    Asset("ANIM", "anim/bamboo_shoot.zip"),                -- 竹笋果实动画
    Asset("ANIM", "anim/dishes_pastoral.zip"),             -- 本mod自己的所有料理

    Asset("ANIM", "anim/fruit_essence.zip"),               -- 丹木提取液动画
    Asset("ANIM", "anim/eggplant_avoiding_needle.zip"),    -- 避茄针动画

    Asset("ATLAS", "images/pastoral_inventoryimages.xml"), -- 物品栏贴图集
    Asset("IMAGE", "images/pastoral_inventoryimages.tex"),
    Asset("ATLAS_BUILD", "images/pastoral_inventoryimages.xml", 256),
}

AddMinimapAtlas("images/pastoral_inventoryimages.xml")

-- 往Assets表里添加动画资源的函数
local function AddAssets(dd)
    for _, v in ipairs(dd) do
        table.insert(Assets, v)
    end
end

--------------------------------------------------------------------------
--[[ 各项设置 ]]
--------------------------------------------------------------------------

_G.SETS_PASTORAL = {
    ENABLEDMODS = {},
    LANGUAGES = GetModConfigData("Language") or "chinese" --语言
}

modimport("scripts/pastoral_globalfn.lua") -- 全局函数
PASTORAL_RegisterInventoryItemAtlas("images/pastoral_inventoryimages.xml")

--------------------------------------------------------------------------
--[[ 判定别的mod是否开启.参考了风铃草大佬的代码,感谢！ ]]
--------------------------------------------------------------------------

local modsenabled = KnownModIndex:GetModsToLoad(true)
local enabledmods = {}
for k, dir in pairs(modsenabled) do
    local info = KnownModIndex:GetModInfo(dir)
    local name = info and info.name or "unknown"
    enabledmods[dir] = name
end
local function IsModEnable(name) -- 不需要弄成全局函数
    for k, v in pairs(enabledmods) do
        if v and (k:match(name) or v:match(name)) then
            return true
        end
    end
    return false
end

_G.SETS_PASTORAL.ENABLEDMODS["legion"] = IsModEnable("Legion") or IsModEnable("棱镜")
_G.SETS_PASTORAL.ENABLEDMODS["legend_of_sea"] = IsModEnable("海洋传说") or TUNING.LEGEND_OF_SEA ~= nil
_G.SETS_PASTORAL.ENABLEDMODS["yq_farming_et"] = IsModEnable("农场补充包") or TUNING.IS_YQ_FARMING_EXTENTION_ENABLED
_G.SETS_PASTORAL.ENABLEDMODS["lykz"] = IsModEnable("龙蝇客栈") or TUNING.LYKZ_MOD_OPRN -- 单词写错了,作者以后可能会改
_G.SETS_PASTORAL.ENABLEDMODS["wulin"] = IsModEnable("武林大会高难作物")
_G.SETS_PASTORAL.ENABLEDMODS["aolai"] = IsModEnable("傲来神仙")
_G.SETS_PASTORAL.ENABLEDMODS["pf_rose"] = IsModEnable("皮服玫瑰")
_G.SETS_PASTORAL.ENABLEDMODS["daogui"] = IsModEnable("道诡异仙")
_G.SETS_PASTORAL.ENABLEDMODS["tastefun"] = IsModEnable("TasteFun") or IsModEnable("食趣") -- 食趣
_G.SETS_PASTORAL.ENABLEDMODS["xzkb"] = IsModEnable("星之卡比") or IsModEnable("workshop%-2591774328") -- 星之卡比
_G.SETS_PASTORAL.ENABLEDMODS["lz"] = IsModEnable("荔只只物语") or IsModEnable("荔只只") or IsModEnable("workshop%-3349143694") -- 荔只只物语

-- 如果没有开启某个mod,添加该mod的预制体代码
if not _G.SETS_PASTORAL.ENABLEDMODS["tastefun"] then
    for k, v in pairs(TF_PrefabFiles) do
        table.insert(PrefabFiles, v)
    end
end

if not _G.SETS_PASTORAL.ENABLEDMODS["xzkb"] then
    for k, v in pairs(XZKB_PrefabFiles) do
        table.insert(PrefabFiles, v)
    end
end

if not _G.SETS_PASTORAL.ENABLEDMODS["daogui"] then
    for k, v in pairs(DAOGUI_PrefabFiles) do
        table.insert(PrefabFiles, v)
    end
end

--------------------------------------------------------------------------
--[[ 各种 ]]
--------------------------------------------------------------------------

local PLANT_DEFS = require("prefabs/farm_plant_defs").PLANT_DEFS
local COMMON = TUNING.SEED_CHANCE_COMMON
local UNCOMMON = TUNING.SEED_CHANCE_UNCOMMON
local RARE = TUNING.SEED_CHANCE_RARE
local moi_low = PLANT_DEFS.carrot.moisture
local moi_med = PLANT_DEFS.pumpkin.moisture
local moi_high = PLANT_DEFS.tomato.moisture
local nut_low = TUNING.FARM_PLANT_CONSUME_NUTRIENT_LOW
local nut_med = TUNING.FARM_PLANT_CONSUME_NUTRIENT_MED
local nut_high = TUNING.FARM_PLANT_CONSUME_NUTRIENT_HIGH

local data_seeds = {}
local ingredients_pl = {}

local function AddSeedData(name, weight)
    data_seeds[name] = {
        seed_weight = weight, -- 只有这里起作用了,其他数据主要是怕被引用到,所以还是填个大概
        health = 1,
        hunger = 1,
        sanity = 1,
        perishtime = 60,
        cooked_health = 1,
        cooked_hunger = 1,
        cooked_sanity = 1,
        cooked_perishtime = 60,
        -- float_settings = nil, cooked_float_settings = nil,
        -- dryable = nil, halloweenmoonmutable_settings = nil, secondary_foodtype = nil, lure_data = nil
    }
end

------------
--本mod
------------

-- 牧歌种子包
AddRecipe2(
    "pastoral_seedpacket",
    { Ingredient("goldnugget", 10) }, --配方
    TECH.SCIENCE_TWO,
    {
        atlas = "images/inventoryimages3.xml",
        image = "yotc_seedpacket_rare.tex",
    },
    {
        "GARDENING", -- 农业分类
    }
)
table.insert(ingredients_pl, { { "piggymimosa" }, { veggie = 1 }, true, false })
-- AddSeedData("piggymimosa", RARE)
PLANT_DEFS.piggymimosa = {
    -- 贴图与动画
    build = "farm_plant_piggymimosa",
    bank = "farm_plant_potato",
    -- 生长时间
    grow_time = PLANT_DEFS.dragonfruit.grow_time,
    -- 需水量
    moisture = moi_med,
    -- 喜好季节
    good_seasons = { autumn = true, spring = true },
    -- 需肥类型
    nutrient_consumption = { 0, nut_med, nut_med },
    -- 会生成的肥料
    nutrient_restoration = { true, nil, nil },
    -- 扫兴容忍度
    max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
    -- 是否随机种子
    is_randomseed = false,
    -- 是否防火
    fireproof = false,
    -- 重量范围
    weight_data = PLANT_DEFS.asparagus.weight_data,
    -- 音效
    sounds = PLANT_DEFS.pepper.sounds,
    -- 作物 代码名称
    prefab = "farm_plant_piggymimosa",
    -- 产物 代码名称
    product = "piggymimosa",
    -- 巨型产物 代码名称
    product_oversized = "piggymimosa_oversized",
    -- 种子 代码名称
    seed = "piggymimosa_seeds",
    -- 家族标签
    plant_type_tag = "farm_plant_piggymimosa",
    -- 巨型产物腐烂后的收获物
    loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "piggymimosa_seeds",
        "fruitfly", "fruitfly", "pinecone" },
    -- 家族化所需数量
    family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
    -- 家族化检索距离
    family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
    -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
    stage_netvar = PLANT_DEFS.pepper.stage_netvar,
    -- 界面相关(官方支持mod使用自己的界面)
    plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
    plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
    -- 图鉴里玩家的庆祝动作
    pictureframeanim = PLANT_DEFS.watermelon.pictureframeanim,
    -- 生长状态(hidden 表示这个阶段不显示)
    plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
}
PLANT_DEFS.pastoral_soybean = {
    -- 贴图与动画
    build = "farm_plant_pastoral_soybean",
    bank = "farm_plant_pastoral_soybean",
    -- 生长时间
    grow_time = PLANT_DEFS.dragonfruit.grow_time,
    -- 需水量
    moisture = moi_low,
    -- 喜好季节
    good_seasons = { autumn = true, summer = true },
    -- 需肥类型
    nutrient_consumption = { 0, nut_med, nut_med },
    -- 会生成的肥料
    nutrient_restoration = { true, nil, nil },
    -- 扫兴容忍度
    max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
    -- 是否随机种子
    is_randomseed = false,
    -- 是否防火
    fireproof = false,
    -- 重量范围
    weight_data = { 328.14, 455.31, .22 },
    -- 音效
    sounds = PLANT_DEFS.tomato.sounds,
    -- 作物 代码名称
    prefab = "farm_plant_pastoral_soybean",
    -- 产物 代码名称
    product = "pastoral_soybean",
    -- 巨型产物 代码名称
    product_oversized = "pastoral_soybean_oversized",
    -- 种子 代码名称
    seed = "pastoral_soybean_seeds",
    -- 家族标签
    plant_type_tag = "farm_plant_pastoral_soybean",
    -- 巨型产物腐烂后的收获物
    loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "pastoral_soybean_seeds",
        "fruitfly", "fruitfly" },
    -- 家族化所需数量
    family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
    -- 家族化检索距离
    family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
    -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
    stage_netvar = PLANT_DEFS.pepper.stage_netvar,
    -- 界面相关(官方支持mod使用自己的界面)
    plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
    plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
    -- 图鉴里玩家的庆祝动作
    pictureframeanim = { anim = "emote_strikepose", time = 23 * FRAMES },
    -- 生长状态(hidden 表示这个阶段不显示)
    plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
}
PLANT_DEFS.bamboo_shoot = {
    -- 贴图与动画
    build = "farm_plant_bamboo_shoot",
    bank = "farm_plant_bamboo_shoot",
    -- 生长时间
    grow_time = PLANT_DEFS.dragonfruit.grow_time,
    -- 需水量
    moisture = moi_med,
    -- 喜好季节
    good_seasons = { winter = true, spring = true },
    -- 需肥类型
    nutrient_consumption = { 0, 0, nut_med },
    -- 会生成的肥料
    nutrient_restoration = { true, true, nil },
    -- 扫兴容忍度
    max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
    -- 是否随机种子
    is_randomseed = false,
    -- 是否防火
    fireproof = false,
    -- 重量范围
    weight_data = PLANT_DEFS.asparagus.weight_data,
    -- 音效
    sounds = PLANT_DEFS.asparagus.sounds,
    -- 作物 代码名称
    prefab = "farm_plant_bamboo_shoot",
    -- 产物 代码名称
    product = "bamboo_shoot",
    -- 巨型产物 代码名称
    product_oversized = "bamboo_shoot_oversized",
    -- 种子 代码名称
    seed = "bamboo_shoot_seeds",
    -- 家族标签
    plant_type_tag = "farm_plant_bamboo_shoot",
    -- 巨型产物腐烂后的收获物
    loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "bamboo_shoot_seeds",
        "fruitfly", "fruitfly" },
    -- 家族化所需数量
    family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
    -- 家族化检索距离
    family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
    -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
    stage_netvar = PLANT_DEFS.pepper.stage_netvar,
    -- 界面相关(官方支持mod使用自己的界面)
    plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
    plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
    -- 图鉴里玩家的庆祝动作
    pictureframeanim = { anim = "emote_flex", time = 21 * FRAMES },
    -- 生长状态(hidden 表示这个阶段不显示)
    plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
}

------------
--棱镜
------------

if not _G.SETS_PASTORAL.ENABLEDMODS["legion"] then
    AddAssets({
        Asset("ANIM", "anim/farm_plant_pineananas.zip"),
        Asset("ANIM", "anim/pineananas.zip"),
        Asset("ANIM", "anim/dishes_pl_legion.zip")
    })
    table.insert(ingredients_pl, { { "pineananas" }, { veggie = 1, fruit = 1 }, true, false })
    -- AddSeedData("pineananas", RARE)
    TUNING.PASTORAL_SEEDPACKET["pineananas_seeds"] = 1
    PLANT_DEFS.pineananas = {
        -- 贴图与动画
        build = "farm_plant_pineananas",
        bank = "farm_plant_pineananas",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 需水量
        moisture = moi_low,
        -- 喜好季节
        good_seasons = { autumn = true, summer = true },
        -- 需肥类型
        nutrient_consumption = { nut_low, 0, nut_low },
        -- 会生成的肥料
        nutrient_restoration = { nil, true, nil },
        -- 扫兴容忍度：0
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- 重量范围
        weight_data = { 422.22, 700.22, 0.93 },
        -- 音效
        sounds = PLANT_DEFS.pepper.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_pineananas",
        -- 产物 代码名称
        product = "pineananas",
        -- 巨型产物 代码名称
        product_oversized = "pineananas_oversized",
        -- 种子 代码名称
        seed = "pineananas_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_pineananas",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "pineananas_seeds",
            "fruitfly", "fruitfly", "pinecone" },
        -- 家族化所需数量：4
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离：5
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS + 1,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = PLANT_DEFS.pepper.pictureframeanim,
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }
end

------------
--海洋传说
------------

local plantregistryinfo_base = {
    {
        text = "seed",
        anim = "crop_seed",
        grow_anim = "grow_seed",
        learnseed = true,
        growing = true,
    },
    {
        text = "sprout",
        anim = "crop_sprout",
        grow_anim = "grow_sprout",
        growing = true,
    },
    {
        text = "small",
        anim = "crop_small",
        grow_anim = "grow_small",
        growing = true,
    },
    {
        text = "medium",
        anim = "crop_med",
        grow_anim = "grow_med",
        growing = true,
    },
    {
        text = "grown",
        anim = "crop_full",
        grow_anim = "grow_full",
        revealplantname = true,
        fullgrown = true,
    },
    {
        text = "oversized",
        anim = "crop_oversized",
        grow_anim = "grow_oversized",
        revealplantname = true,
        fullgrown = true,
        -- hidden = true, --与官方数据唯一的区别
    },
    {
        text = "rotting",
        anim = "crop_rot",
        grow_anim = "grow_rot",
        stagepriority = -100,
        is_rotten = true,
        hidden = true,
    },
    {
        text = "oversized_rotting",
        anim = "crop_rot_oversized",
        grow_anim = "grow_rot_oversized",
        stagepriority = -100,
        is_rotten = true,
        hidden = true,
    }
}

if not _G.SETS_PASTORAL.ENABLEDMODS["legend_of_sea"] then
    AddAssets({
        Asset("ANIM", "anim/farm_plant_lg_mangguo.zip"),
        Asset("ANIM", "anim/lg_mangguo.zip"),
        Asset("ANIM", "anim/farm_plant_lg_putao.zip"),
        Asset("ANIM", "anim/lg_putao.zip")
    })
    table.insert(ingredients_pl, { { "lg_mangguo", "lg_putao" }, { fruit = 1 }, true, false })
    -- AddSeedData("lg_mangguo", UNCOMMON)
    -- AddSeedData("lg_putao", UNCOMMON)
    TUNING.PASTORAL_SEEDPACKET["lg_mangguo_seeds"] = 1
    TUNING.PASTORAL_SEEDPACKET["lg_putao_seeds"] = 1
    PLANT_DEFS.lg_mangguo = {
        -- 贴图
        build = "farm_plant_lg_mangguo",
        bank = "farm_plant_potato",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 潮湿度
        moisture = moi_high,
        -- 适应的季节
        good_seasons = { summer = true, spring = true },
        -- 需求的肥料
        nutrient_consumption = { 0, nut_low, nut_low },
        -- 会生成的肥料
        nutrient_restoration = { true, nil, nil },
        -- 好感度
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否免疫火
        -- fireproof = true,
        -- 称重
        weight_data = { 666.66, 888.88, 2.34 },
        -- 植物代码
        prefab = "farm_plant_lg_mangguo",
        -- 产物
        product = "lg_mangguo",
        -- 巨大产物
        product_oversized = "lg_mangguo_oversized",
        -- 种子
        seed = "lg_mangguo_seeds",
        -- 标签
        plant_type_tag = "farm_plant_lg_mangguo",
        -- 腐烂产物(大型的腐烂)
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "lg_mangguo_seeds", "fruitfly", "fruitfly" },
        -- 家族化需求的数量(也就是家族化检索距离里面至少有几个才可以长出来巨大型的最少数量 默认4)
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离(默认4)
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 生长图谱 (hidden 表示这个阶段不显示)
        sounds = PLANT_DEFS.potato.sounds,
        plantregistryinfo = plantregistryinfo_base,
        -- 界面相关  官方支持mod使用自己的界面
        plantregistrywidget = "widgets/redux/farmplantpage",
        plantregistrysummarywidget = "widgets/redux/farmplantsummarywidget",
        pictureframeanim = { anim = "emoteXL_happycheer", time = 0.5 }
    }
    PLANT_DEFS.lg_putao = {
        -- 贴图与动画
        build = "farm_plant_lg_putao",
        bank = "farm_plant_potato",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 需水量
        moisture = moi_low,
        -- 喜好季节
        good_seasons = { autumn = true, spring = true },
        -- 需肥类型
        nutrient_consumption = { 0, 0, nut_high },
        -- 会生成的肥料
        nutrient_restoration = { true, true, nil },
        -- 扫兴容忍度：0
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- 重量范围
        weight_data = { 666.66, 888.88, 2.34 },
        -- 音效
        sounds = PLANT_DEFS.potato.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_lg_putao",
        -- 产物 代码名称
        product = "lg_putao",
        -- 巨型产物 代码名称
        product_oversized = "lg_putao_oversized",
        -- 种子 代码名称
        seed = "lg_putao_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_lg_putao",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "lg_putao_seeds", "fruitfly", "fruitfly" },
        -- 家族化所需数量：4
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离：4
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = "widgets/redux/farmplantpage",
        plantregistrysummarywidget = "widgets/redux/farmplantsummarywidget",
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = { anim = "emoteXL_happycheer", time = 0.5 },
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = plantregistryinfo_base
    }
end

------------
--农场补充包
------------

if not _G.SETS_PASTORAL.ENABLEDMODS["yq_farming_et"] then
    AddAssets({
        Asset("ANIM", "anim/farm_plant_yq_baicai.zip"),
        Asset("ANIM", "anim/yq_baicai.zip"),
        Asset("ANIM", "anim/farm_plant_yq_bocai.zip"),
        Asset("ANIM", "anim/yq_bocai.zip"),
        Asset("ANIM", "anim/farm_plant_yq_dacong.zip"),
        Asset("ANIM", "anim/yq_dacong.zip"),
        Asset("ANIM", "anim/farm_plant_yq_jiang.zip"),
        Asset("ANIM", "anim/yq_jiang.zip")
    })
    table.insert(ingredients_pl, { { "yq_baicai", "yq_bocai", "yq_dacong", "yq_jiang" }, { veggie = 1 }, true, false })
    AddRecipe2( -- 白菜
        "yq_baicai_seeds", {
            Ingredient("seeds", 5),
            Ingredient("spoiled_food", 5)
        }, TECH.SCIENCE_ONE, { numtogive = 5 },
        { "REFINE" }
    )
    AddRecipe2( -- 大葱
        "yq_dacong_seeds", {
            Ingredient("seeds", 5),
            Ingredient("rottenegg", 5)
        }, TECH.SCIENCE_ONE, { numtogive = 5 },
        { "REFINE" }
    )
    AddRecipe2( -- 姜
        "yq_jiang_seeds", {
            Ingredient("seeds", 5),
            Ingredient("poop", 5)
        }, TECH.SCIENCE_ONE, { numtogive = 5 },
        { "REFINE" }
    )
    AddRecipe2( -- 香菜
        "yq_bocai_seeds", {
            Ingredient("seeds", 5),
            Ingredient("spoiled_fish_small", 5)
        }, TECH.SCIENCE_ONE, { numtogive = 5 },
        { "REFINE" }
    )

    PLANT_DEFS.yq_baicai = {
        -- 贴图与动画
        build = "farm_plant_yq_baicai",
        bank = "farm_plant_pumpkin",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 需水量
        moisture = moi_low,
        -- 喜好季节
        good_seasons = { autumn = true, spring = true, winter = true },
        -- 需肥类型
        nutrient_consumption = { 0, nut_med, 0 },
        -- 会生成的肥料
        nutrient_restoration = { true, nil, true },
        -- 扫兴容忍度：0
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- 重量范围
        weight_data = PLANT_DEFS.corn.weight_data,
        -- 音效
        sounds = PLANT_DEFS.potato.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_yq_baicai",
        -- 产物 代码名称
        product = "yq_baicai",
        -- 巨型产物 代码名称
        product_oversized = "yq_baicai_oversized",
        -- 种子 代码名称
        seed = "yq_baicai_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_yq_baicai",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "yq_baicai_seeds", "fruitfly", "fruitfly" },
        -- 家族化所需数量：4
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离：4
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = PLANT_DEFS.corn.pictureframeanim,
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = plantregistryinfo_base
    }
    PLANT_DEFS.yq_bocai = {
        -- 贴图与动画
        build = "farm_plant_yq_bocai",
        bank = "farm_plant_asparagus",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 需水量
        moisture = moi_med,
        -- 喜好季节
        good_seasons = { autumn = true, spring = true, winter = true },
        -- 需肥类型
        nutrient_consumption = { 0, 0, nut_med },
        -- 会生成的肥料
        nutrient_restoration = { true, true, nil },
        -- 扫兴容忍度：0
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- 重量范围
        weight_data = PLANT_DEFS.garlic.weight_data,
        -- 音效
        sounds = PLANT_DEFS.potato.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_yq_bocai",
        -- 产物 代码名称
        product = "yq_bocai",
        -- 巨型产物 代码名称
        product_oversized = "yq_bocai_oversized",
        -- 种子 代码名称
        seed = "yq_bocai_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_yq_bocai",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "yq_bocai_seeds", "fruitfly", "fruitfly" },
        -- 家族化所需数量：4
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离：4
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = PLANT_DEFS.potato.pictureframeanim,
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = plantregistryinfo_base
    }
    PLANT_DEFS.yq_dacong = {
        -- 贴图与动画
        build = "farm_plant_yq_dacong",
        bank = "farm_plant_carrot",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 需水量
        moisture = moi_low,
        -- 喜好季节
        good_seasons = { autumn = true, spring = true, summer = true },
        -- 需肥类型
        nutrient_consumption = { nut_high, 0, 0 },
        -- 会生成的肥料
        nutrient_restoration = { nil, true, true },
        -- 扫兴容忍度：0
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- 重量范围
        weight_data = PLANT_DEFS.onion.weight_data,
        -- 音效
        sounds = PLANT_DEFS.potato.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_yq_dacong",
        -- 产物 代码名称
        product = "yq_dacong",
        -- 巨型产物 代码名称
        product_oversized = "yq_dacong_oversized",
        -- 种子 代码名称
        seed = "yq_dacong_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_yq_dacong",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "yq_dacong_seeds", "fruitfly", "fruitfly" },
        -- 家族化所需数量：4
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离：4
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = PLANT_DEFS.tomato.pictureframeanim,
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = plantregistryinfo_base
    }
    PLANT_DEFS.yq_jiang = {
        -- 贴图与动画
        build = "farm_plant_yq_jiang",
        bank = "farm_plant_garlic",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 需水量
        moisture = moi_low,
        -- 喜好季节
        good_seasons = { autumn = true, spring = true, summer = true, winter = true },
        -- 需肥类型
        nutrient_consumption = { 0, nut_high, 0 },
        -- 会生成的肥料
        nutrient_restoration = { true, nil, true },
        -- 扫兴容忍度：0
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- 重量范围
        weight_data = PLANT_DEFS.eggplant.weight_data,
        -- 音效
        sounds = PLANT_DEFS.potato.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_yq_jiang",
        -- 产物 代码名称
        product = "yq_jiang",
        -- 巨型产物 代码名称
        product_oversized = "yq_jiang_oversized",
        -- 种子 代码名称
        seed = "yq_jiang_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_yq_jiang",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "yq_jiang_seeds", "fruitfly", "fruitfly" },
        -- 家族化所需数量：4
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离：4
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = PLANT_DEFS.asparagus.pictureframeanim,
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = plantregistryinfo_base
    }
end

------------
--龙蝇客栈
------------

if not _G.SETS_PASTORAL.ENABLEDMODS["lykz"] then
    AddAssets({
        Asset("ANIM", "anim/farm_plant_danmu.zip"),
        Asset("ANIM", "anim/danmu.zip")
    })

    local function MakeGrowTimes_danmu(germination_min, germination_max, full_grow_min, full_grow_max)
        local grow_time     = {}

        -- germination time
        grow_time.seed      = { germination_min, germination_max }

        -- grow time
        grow_time.sprout    = { full_grow_min * 0.5, full_grow_max * 0.5 }
        grow_time.small     = { full_grow_min * 0.3, full_grow_max * 0.3 }
        grow_time.med       = { full_grow_min * 0.2, full_grow_max * 0.2 }

        -- harvestable perish time
        grow_time.full      = 999 * TUNING.TOTAL_DAY_TIME
        grow_time.oversized = 999 * TUNING.TOTAL_DAY_TIME
        grow_time.regrow    = { 10 * TUNING.TOTAL_DAY_TIME, 15 * TUNING.TOTAL_DAY_TIME } -- min, max

        return grow_time
    end
    PLANT_DEFS.danmu = {
        -- 贴图与动画
        build = "farm_plant_danmu",
        bank = "farm_plant_danmu",
        -- 生长时间
        grow_time = MakeGrowTimes_danmu(10 * TUNING.TOTAL_DAY_TIME, 20 * TUNING.TOTAL_DAY_TIME,
            20 * TUNING.TOTAL_DAY_TIME, 30 * TUNING.TOTAL_DAY_TIME),
        -- 需水量
        moisture = { drink_rate = TUNING.FARM_PLANT_DRINK_LOW, min_percent = 0 },
        -- 喜好季节
        good_seasons = { autumn = true, spring = true, summer = true, winter = true },
        -- 需肥类型
        nutrient_consumption = { 10, 0, 10 }, -- 原版最多消耗值为8
        -- 会生成的肥料
        nutrient_restoration = { nil, true, nil },
        -- 扫兴容忍度：0
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = true,
        -- 重量范围
        weight_data = { 444.44, 666.66, 0.88 },
        -- 音效
        sounds = PLANT_DEFS.potato.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_danmu",
        -- 产物 代码名称
        product = "danmu",
        -- 巨型产物 代码名称
        product_oversized = "danmu_oversized",
        -- 种子 代码名称
        seed = "danmu_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_danmu",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "danmu_seeds", "fruitfly", "fruitfly" },
        -- 家族化所需数量
        family_min_count = 1,   -- 一般是4
        -- 家族化检索距离
        family_check_dist = 10, -- 一般是4
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = PLANT_DEFS.pepper.pictureframeanim,
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }

    if IsServer then
        AddComponentPostInit("hunger", function(self)
            local old_DoDelta = self.DoDelta
            function self:DoDelta(delta, ...)
                if delta and delta < 0 and self.inst:HasTag("danmufx") then return end
                if old_DoDelta then old_DoDelta(self, delta, ...) end
            end
        end)
        AddComponentPostInit("temperature", function(self) -- 温度控制
            local old_SetTemperature = self.SetTemperature
            function self:SetTemperature(value, ...)
                -- if value < 10 and (self.inst:HasTag("chililongwei") or self.inst:HasTag("lykztea_wl_buff")) then--有特殊标签则体温不会低于10
                --     value = 10
                -- end
                if -- 有特殊标签则体温不会高于最高耐受温度-10
                    value > (self.overheattemp - 10) and
                    (self.inst:HasTag("longying") or self.inst:HasTag("lykztea_nm_buff") or self.inst:HasTag("danmufx"))
                then
                    value = self.overheattemp - 10
                end
                return old_SetTemperature(self, value, ...)
            end
        end)
        AddPrefabPostInit("dragonfly", function(inst) -- 龙蝇有几率掉落丹木种子
            inst:ListenForEvent("death", function(inst, data)
                if inst.components.lootdropper ~= nil then
                    if math.random() < 0.2 then
                        inst.components.lootdropper:SpawnLootPrefab("danmu_seeds")
                    end
                end
            end)
        end)
    end
end

------------
--武林大会高难作物
------------

if not _G.SETS_PASTORAL.ENABLEDMODS["wulin"] then
    AddAssets({
        Asset("ANIM", "anim/farm_plant_gzresource_apple.zip"),
        Asset("ANIM", "anim/farm_plant_gzresource_lemon.zip"),
        Asset("ANIM", "anim/farm_plant_gzresource_mango.zip"),
        Asset("ANIM", "anim/farm_plant_gzresource_orange.zip"),
        Asset("ANIM", "anim/farm_plant_gzresource_strawberry.zip"),
        Asset("ANIM", "anim/farm_plant_gzresource_sugarbeet.zip"),
        Asset("ANIM", "anim/farm_plant_gzresource_whitegourd.zip"),
        Asset("ANIM", "anim/gzresource.zip"), -- 没错,它的所有小物件动画集中在了一起,代码上还要额外兼容
    })

    table.insert(ingredients_pl, {
        { "gzresource_strawberry", "gzresource_orange", "gzresource_apple", "gzresource_lemon", "gzresource_mango" },
        { fruit = 1 }, true, false
    })
    table.insert(ingredients_pl, { { "gzresource_whitegourd", "gzresource_sugarbeet" }, { veggie = 1 }, true, false })
    table.insert(ingredients_pl, {
        { "gzresource_strawberry_advanced", "gzresource_orange_advanced", "gzresource_apple_advanced",
            "gzresource_lemon_advanced", "gzresource_mango_advanced" },
        { fruit = 3 }, false, false
    })
    table.insert(ingredients_pl, {
        { "gzresource_whitegourd_advanced", "gzresource_sugarbeet_advanced" },
        { veggie = 3 }, false, false
    })

    -- AddSeedData("gzresource_apple", RARE)
    -- AddSeedData("gzresource_lemon", RARE)
    -- AddSeedData("gzresource_mango", RARE)
    -- AddSeedData("gzresource_orange", RARE)
    -- AddSeedData("gzresource_strawberry", RARE)
    -- AddSeedData("gzresource_sugarbeet", RARE)
    -- AddSeedData("gzresource_whitegourd", RARE)
    TUNING.PASTORAL_SEEDPACKET["gzresource_apple_seeds"] = 1
    TUNING.PASTORAL_SEEDPACKET["gzresource_lemon_seeds"] = 1
    TUNING.PASTORAL_SEEDPACKET["gzresource_mango_seeds"] = 1
    TUNING.PASTORAL_SEEDPACKET["gzresource_orange_seeds"] = 1
    TUNING.PASTORAL_SEEDPACKET["gzresource_strawberry_seeds"] = 1
    TUNING.PASTORAL_SEEDPACKET["gzresource_sugarbeet_seeds"] = 1
    TUNING.PASTORAL_SEEDPACKET["gzresource_whitegourd_seeds"] = 1

    local function MakeSeasons(spring, summer, autumn, winter)
        return { spring = spring, summer = summer, autumn = autumn, winter = winter }
    end
    local function AddWuLinCrop(name, bank, drink, cons, rest, seasons, weight)
        PLANT_DEFS[name] = {
            -- 贴图与动画
            build = "farm_plant_" .. name,
            bank = bank or ("farm_plant_" .. name),
            -- 生长时间
            grow_time = PLANT_DEFS.dragonfruit.grow_time,
            -- 需水量
            moisture = drink,
            -- 喜好季节
            good_seasons = seasons,
            -- 需肥类型
            nutrient_consumption = cons,
            -- 会生成的肥料
            nutrient_restoration = rest,
            -- 扫兴容忍度
            max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
            -- 怎么可能是随机种子！
            is_randomseed = false,
            -- 高难就得牛逼点,不怕烧
            fireproof = true,
            -- 重量范围
            weight_data = weight,
            -- 音效照抄！
            sounds = PLANT_DEFS.pepper.sounds,
            -- 作物 代码名称
            prefab = "farm_plant_" .. name,
            -- 产物 代码名称
            product = name,
            -- 巨型产物 代码名称
            product_oversized = name .. "_oversized",
            -- 种子 代码名称
            seed = name .. "_seeds",
            -- 标签
            plant_type_tag = "farm_plant_" .. name,
            -- 巨型产物腐烂后的收获物
            loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", name .. "_seeds", "fruitfly", "fruitfly" },
            -- 家族化所需数量：4
            family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
            -- 家族化检索距离：4
            family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
            -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
            stage_netvar = PLANT_DEFS.pepper.stage_netvar,
            -- 界面相关(原mod使用了自己的界面,但好像多了别的设定,所以这里就不加了)
            plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
            plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
            -- 图鉴里玩家的庆祝动作
            pictureframeanim = PLANT_DEFS.pepper.pictureframeanim,
            -- 图鉴信息(hidden 表示这个阶段不显示)
            plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo,
            -- 原mod自己的参数,貌似没什么用
            is_gzresource = true
        }
    end
    AddWuLinCrop("gzresource_strawberry", "farm_plant_potato", moi_high,
        { 4, 22, 0 }, { nil, nil, true }, MakeSeasons(true, nil, nil, true), { 290, 550, 0.9 })
    AddWuLinCrop("gzresource_orange", "farm_plant_tomato", moi_high,
        { 0, 16, 10 }, { true, nil, nil }, MakeSeasons(nil, true, nil, nil), { 335, 765, 0.9 })
    AddWuLinCrop("gzresource_sugarbeet", "farm_plant_garlic", moi_low,
        { 2, 0, 2 }, { nil, true, nil }, MakeSeasons(true, true, true, true), { 250, 925, 0.9 })
    AddWuLinCrop("gzresource_apple", "farm_plant_tomato", moi_med,
        { 0, 8, 2 }, { true, nil, nil }, MakeSeasons(nil, nil, true, nil), { 465, 875, 0.9 })
    AddWuLinCrop("gzresource_lemon", "farm_plant_potato", moi_med,
        { 12, 6, 0 }, { nil, nil, true }, MakeSeasons(true, nil, true, nil), { 175, 500, 0.9 })
    AddWuLinCrop("gzresource_mango", "farm_plant_potato", moi_high,
        { 0, 24, 0 }, { true, nil, nil }, MakeSeasons(nil, true, nil, true), { 125, 890, 0.9 })
    AddWuLinCrop("gzresource_whitegourd", "farm_plant_tomato", moi_high,
        { 4, 16, 0 }, { nil, nil, true }, MakeSeasons(true, nil, true, nil), { 90, 990, 0.9 })
end

------------
--傲来神仙境
------------

if not _G.SETS_PASTORAL.ENABLEDMODS["aolai"] then
    AddAssets({
        Asset("ANIM", "anim/farm_plant_wheat_myth.zip"),
        Asset("ANIM", "anim/wheat_myth.zip"),
        Asset("ANIM", "anim/farm_plant_cabbage_myth.zip"),
        Asset("ANIM", "anim/cabbage_myth.zip"),
        Asset("ANIM", "anim/farm_plant_jasminebean.zip"), -- 一会有myth后缀一会没有,最好统一下,并且不需要的文件就该删了吧
        Asset("ANIM", "anim/jasminebean.zip")
    })
    table.insert(ingredients_pl, { { "wheat_myth", "cabbage_myth", "jasminebean" }, { veggie = 1 }, true, false })
    -- AddSeedData("wheat_myth", UNCOMMON)
    -- AddSeedData("cabbage_myth", UNCOMMON)
    -- AddSeedData("jasminebean", UNCOMMON)
    TUNING.PASTORAL_SEEDPACKET["wheat_myth_seeds"] = 1
    TUNING.PASTORAL_SEEDPACKET["cabbage_myth_seeds"] = 1
    TUNING.PASTORAL_SEEDPACKET["jasminebean_seeds"] = 1

    PLANT_DEFS.wheat_myth = {
        -- 贴图与动画
        build = "farm_plant_wheat_myth",
        bank = "farm_plant_wheat_myth",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 需水量
        moisture = moi_low,
        -- 喜好季节
        good_seasons = { winter = true, spring = true },
        -- 需肥类型
        nutrient_consumption = { nut_low, nut_low, 0 },
        -- 会生成的肥料
        nutrient_restoration = { nil, nil, true },
        -- 扫兴容忍度
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- 重量范围
        weight_data = { 422.22, 700.22, 0.93 },
        -- 音效
        sounds = PLANT_DEFS.pepper.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_wheat_myth",
        -- 产物 代码名称
        product = "wheat_myth",
        -- 巨型产物 代码名称
        product_oversized = "wheat_myth_oversized",
        -- 种子 代码名称
        seed = "wheat_myth_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_wheat_myth",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "wheat_myth_seeds",
            "fruitfly", "fruitfly" },
        -- 家族化所需数量
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS + 1,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = PLANT_DEFS.pumpkin.pictureframeanim,
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }
    PLANT_DEFS.cabbage_myth = {
        -- 贴图与动画
        build = "farm_plant_cabbage_myth",
        bank = "farm_plant_cabbage_myth",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 需水量
        moisture = moi_low,
        -- 喜好季节
        good_seasons = { autumn = true, summer = true },
        -- 需肥类型
        nutrient_consumption = { 0, nut_low, nut_low },
        -- 会生成的肥料
        nutrient_restoration = { true, nil, nil },
        -- 扫兴容忍度
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- 重量范围
        weight_data = { 422.22, 700.22, 0.93 },
        -- 音效
        sounds = PLANT_DEFS.pepper.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_cabbage_myth",
        -- 产物 代码名称
        product = "cabbage_myth",
        -- 巨型产物 代码名称
        product_oversized = "cabbage_myth_oversized",
        -- 种子 代码名称
        seed = "cabbage_myth_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_cabbage_myth",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "cabbage_myth_seeds",
            "fruitfly", "fruitfly" },
        -- 家族化所需数量
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS + 1,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = PLANT_DEFS.dragonfruit.pictureframeanim,
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }
    PLANT_DEFS.jasminebean = {
        -- 贴图与动画
        build = "farm_plant_jasminebean",
        bank = "farm_plant_jasminebean",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 需水量
        moisture = moi_med,
        -- 喜好季节
        good_seasons = { summer = true, spring = true },
        -- 需肥类型
        nutrient_consumption = { nut_low, 0, nut_low },
        -- 会生成的肥料
        nutrient_restoration = { nil, true, nil },
        -- 扫兴容忍度
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- 重量范围
        weight_data = { 422.22, 700.22, 0.93 },
        -- 音效
        sounds = PLANT_DEFS.pepper.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_jasminebean",
        -- 产物 代码名称
        product = "jasminebean",
        -- 巨型产物 代码名称
        product_oversized = "jasminebean_oversized",
        -- 种子 代码名称
        seed = "jasminebean_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_jasminebean",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "jasminebean_seeds",
            "fruitfly", "fruitfly" },
        -- 家族化所需数量
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS + 1,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = PLANT_DEFS.durian.pictureframeanim,
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }
end

------------
--皮服玫瑰
------------

-- 由于本mod对皮服玫瑰的动画与代码进行了补充,所以不再适合与皮服玫瑰mod一起使用.因此这里不再增加逻辑判断

AddAssets({
    Asset("ANIM", "anim/farm_plant_pm_rose.zip"),
    Asset("ANIM", "anim/farm_plant_pm_rose_fix.zip"),                                            -- 对动画进行了补充
    Asset("ANIM", "anim/pm_rose.zip")                                                            -- 对动画进行了整合
})
table.insert(ingredients_pl, { { "pm_rose" }, { veggie = 1, petals_legion = 1 }, false, false }) -- 原mod里貌似也无法放入烹饪锅
-- AddSeedData("pm_rose", UNCOMMON)
TUNING.PASTORAL_SEEDPACKET["pm_rose_seeds"] = 1
PLANT_DEFS.pm_rose = {
    -- 贴图与动画
    build = "farm_plant_pm_rose",
    bank = "farm_plant_potato",
    -- 生长时间
    grow_time = PLANT_DEFS.dragonfruit.grow_time,
    -- 需水量
    moisture = moi_high,
    -- 喜好季节
    good_seasons = { autumn = true, summer = true, spring = true },
    -- 需肥类型
    nutrient_consumption = { 0, nut_low, nut_low },
    -- 会生成的肥料
    nutrient_restoration = { true, nil, nil },
    -- 扫兴容忍度
    max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
    -- 是否随机种子
    is_randomseed = false,
    -- 是否防火
    fireproof = false,
    -- 重量范围
    weight_data = { 166.51, 299.234, 0.28 },
    -- 音效
    sounds = PLANT_DEFS.pepper.sounds,
    -- 作物 代码名称
    prefab = "farm_plant_pm_rose",
    -- 产物 代码名称
    product = "pm_rose",
    -- 巨型产物 代码名称
    product_oversized = "pm_rose_oversized",
    -- 种子 代码名称
    seed = "pm_rose_seeds",
    -- 家族标签
    plant_type_tag = "farm_plant_pm_rose",
    -- 巨型产物腐烂后的收获物
    loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "pm_rose_seeds",
        "fruitfly", "fruitfly" },
    -- 家族化所需数量
    family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
    -- 家族化检索距离
    family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
    -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
    stage_netvar = PLANT_DEFS.pepper.stage_netvar,
    -- 界面相关(官方支持mod使用自己的界面)
    plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
    plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
    -- 图鉴里玩家的庆祝动作
    pictureframeanim = PLANT_DEFS.onion.pictureframeanim,
    -- 生长状态(hidden 表示这个阶段不显示)
    plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
}

------------
--道诡异仙
------------

if not _G.SETS_PASTORAL.ENABLEDMODS["daogui"] then
    modimport("scripts/pastoral_weed_defs.lua") -- 灵芝和人参
    TUNING.PASTORAL_SEEDPACKET["daogui_ginseng_seeds"] = 1
    TUNING.PASTORAL_SEEDPACKET["daogui_ganoderma_seeds"] = 1
    AddAssets({
        Asset("ANIM", "anim/farm_plant_daogui_hmg.zip"),
        Asset("ANIM", "anim/daogui_hmg_plant.zip")
    })
    table.insert(ingredients_pl, { { "daogui_hmg" }, { fruit = 1 }, true, false })
    -- AddSeedData("daogui_hmg", RARE)
    TUNING.PASTORAL_SEEDPACKET["daogui_hmg_seeds"] = 1
    PLANT_DEFS.daogui_hmg = {
        -- 贴图与动画
        build = "farm_plant_daogui_hmg",
        bank = "farm_plant_tomato",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 需水量
        moisture = moi_high,
        -- 喜好季节
        good_seasons = { summer = true, spring = true },
        -- 需肥类型
        nutrient_consumption = { 0, nut_low, nut_low },
        -- 会生成的肥料
        nutrient_restoration = { true, nil, nil },
        -- 扫兴容忍度
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- 重量范围
        weight_data = PLANT_DEFS.watermelon.weight_data,
        -- 音效
        sounds = PLANT_DEFS.pepper.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_daogui_hmg",
        -- 产物 代码名称
        product = "daogui_hmg",
        -- 巨型产物 代码名称
        product_oversized = "daogui_hmg_oversized",
        -- 种子 代码名称
        seed = "daogui_hmg_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_daogui_hmg",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "daogui_hmg_seeds",
            "fruitfly", "fruitfly" },
        -- 家族化所需数量
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = PLANT_DEFS.pomegranate.pictureframeanim,
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }
end

------------
--食趣
------------

if not _G.SETS_PASTORAL.ENABLEDMODS["tastefun"] then
    AddAssets({
        Asset("ANIM", "anim/farm_plant_tf_orange.zip"),
        Asset("ANIM", "anim/tf_orange.zip"),
        Asset("ANIM", "anim/farm_plant_tf_strawberry.zip"),
        Asset("ANIM", "anim/tf_strawberry.zip"),
        Asset("ANIM", "anim/farm_plant_tf_cabbage.zip"),
        Asset("ANIM", "anim/tf_cabbage.zip"),
        Asset("ANIM", "anim/farm_plant_tf_green_pepper.zip"),
        Asset("ANIM", "anim/tf_green_pepper.zip"),
    })
    table.insert(ingredients_pl, { { "tf_orange" }, { fruit = 1 }, true, false })
    table.insert(ingredients_pl, { { "tf_strawberry" }, { fruit = 1 }, true, false })
    table.insert(ingredients_pl, { { "tf_cabbage" }, { fruit = 1 }, true, false })
    table.insert(ingredients_pl, { { "tf_green_pepper" }, { fruit = 1 }, true, false })
    -- 食趣种子包
    AddRecipe2(
        "tf_seedpacket",
        { Ingredient("goldnugget", 3) }, --配方
        TECH.SCIENCE_TWO,
        {
            atlas = "images/inventoryimages3.xml",
            image = "yotc_seedpacket_rare.tex",
        },
        {
            "GARDENING", -- 农业分类
        }
    )
    -- 橘子酱
    AddRecipe2(
        "spice_tf_orange_jam",
        { Ingredient("tf_orange", 4) },
        TECH.FOODPROCESSING_ONE,
        {
            builder_tag = "professionalchef",
            numtogive = 3,
            nounlock = true
        }
    )
    -- 草莓酱
    AddRecipe2(
        "spice_tf_strawberry_jam",
        { Ingredient("tf_strawberry", 4) },
        TECH.FOODPROCESSING_ONE,
        {
            builder_tag = "professionalchef",
            numtogive = 3,
            nounlock = true
        }
    )
    PLANT_DEFS.tf_orange = {
        -- ※表示大概率要改,没有就表示大概率所有农作物都一致
        -- ※贴图与动画
        build = "farm_plant_tf_orange",
        bank = "farm_plant_tf_orange",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time, -- 大多数情况下都是一样的
        -- ※需水量
        moisture = moi_low,
        -- ※喜好季节
        good_seasons = { autumn = true, spring = true, summer = true },
        -- ※需肥类型
        nutrient_consumption = { 0, nut_med, nut_med },
        -- ※会生成的肥料
        nutrient_restoration = { true, nil, nil },
        -- 扫兴容忍度
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- ※重量范围
        weight_data = { 340.20, 582.64, .48 },
        -- ※音效
        sounds = PLANT_DEFS.potato.sounds,
        -- ※作物 代码名称
        prefab = "farm_plant_tf_orange",
        -- ※产物 代码名称
        product = "tf_orange",
        -- ※巨型产物 代码名称
        product_oversized = "tf_orange_oversized",
        -- ※种子 代码名称
        seed = "tf_orange_seeds",
        -- ※家族标签
        plant_type_tag = "farm_plant_tf_orange",
        -- ※巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "tf_orange_seeds",
            "fruitfly", "fruitfly" },
        -- 家族化所需数量
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- ※图鉴里玩家的庆祝动作
        pictureframeanim = { anim = "emoteXL_loop_dance7", time = 37 * FRAMES },
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }
    PLANT_DEFS.tf_strawberry = {
        -- ※表示大概率要改,没有就表示大概率所有农作物都一致
        -- ※贴图与动画
        build = "farm_plant_tf_strawberry",
        bank = "farm_plant_tf_strawberry",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time, -- 大多数情况下都是一样的
        -- ※需水量
        moisture = moi_low,
        -- ※喜好季节
        good_seasons = { spring = true, summer = true },
        -- ※需肥类型
        nutrient_consumption = { nut_med, nut_med, 0 },
        -- ※会生成的肥料
        nutrient_restoration = { nil, nil, true },
        -- 扫兴容忍度
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- ※重量范围
        weight_data = { 384.59, 662.77, .18 },
        -- ※音效
        sounds = PLANT_DEFS.potato.sounds,
        -- ※作物 代码名称
        prefab = "farm_plant_tf_strawberry",
        -- ※产物 代码名称
        product = "tf_strawberry",
        -- ※巨型产物 代码名称
        product_oversized = "tf_strawberry_oversized",
        -- ※种子 代码名称
        seed = "tf_strawberry_seeds",
        -- ※家族标签
        plant_type_tag = "farm_plant_tf_strawberry",
        -- ※巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "tf_strawberry_seeds",
            "fruitfly", "fruitfly" },
        -- 家族化所需数量
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- ※图鉴里玩家的庆祝动作
        pictureframeanim = { anim = "emoteXL_loop_dance0", time = 7 * FRAMES },
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }
    PLANT_DEFS.tf_cabbage = {
        -- ※表示大概率要改,没有就表示大概率所有农作物都一致
        -- ※贴图与动画
        build = "farm_plant_tf_cabbage",
        bank = "farm_plant_tf_cabbage",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time, -- 大多数情况下都是一样的
        -- ※需水量
        moisture = moi_med,
        -- ※喜好季节
        good_seasons = { autumn = true, spring = true },
        -- ※需肥类型
        nutrient_consumption = { 0, nut_med, 0 },
        -- ※会生成的肥料
        nutrient_restoration = { true, nil, true },
        -- 扫兴容忍度
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- ※重量范围
        weight_data = { 361.51, 506.04, .28 },
        -- ※音效
        sounds = PLANT_DEFS.potato.sounds,
        -- ※作物 代码名称
        prefab = "farm_plant_tf_cabbage",
        -- ※产物 代码名称
        product = "tf_cabbage",
        -- ※巨型产物 代码名称
        product_oversized = "tf_cabbage_oversized",
        -- ※种子 代码名称
        seed = "tf_cabbage_seeds",
        -- ※家族标签
        plant_type_tag = "farm_plant_tf_cabbage",
        -- ※巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "tf_cabbage_seeds",
            "fruitfly", "fruitfly" },
        -- 家族化所需数量
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- ※图鉴里玩家的庆祝动作
        pictureframeanim = { anim = "emote_happycheer", time = 12 * FRAMES },
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }
    PLANT_DEFS.tf_green_pepper = {
        -- ※表示大概率要改,没有就表示大概率所有农作物都一致
        -- ※贴图与动画
        build = "farm_plant_tf_green_pepper",
        bank = "farm_plant_tf_green_pepper",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time, -- 大多数情况下都是一样的
        -- ※需水量
        moisture = moi_low,
        -- ※喜好季节
        good_seasons = { autumn = true, spring = true },
        -- ※需肥类型
        nutrient_consumption = { nut_med, 0, 0 },
        -- ※会生成的肥料
        nutrient_restoration = { nil, true, true },
        -- 扫兴容忍度
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- ※重量范围
        weight_data = { 368.55, 486.32, .11 },
        -- ※音效
        sounds = PLANT_DEFS.pepper.sounds,
        -- ※作物 代码名称
        prefab = "farm_plant_tf_green_pepper",
        -- ※产物 代码名称
        product = "tf_green_pepper",
        -- ※巨型产物 代码名称
        product_oversized = "tf_green_pepper_oversized",
        -- ※种子 代码名称
        seed = "tf_green_pepper_seeds",
        -- ※家族标签
        plant_type_tag = "farm_plant_tf_green_pepper",
        -- ※巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "tf_green_pepper_seeds",
            "fruitfly", "fruitfly" },
        -- 家族化所需数量
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- ※图鉴里玩家的庆祝动作
        pictureframeanim = { anim = "emote_swoon", time = 37 * FRAMES },
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }
end

------------
--星之卡比
------------

if not _G.SETS_PASTORAL.ENABLEDMODS["xzkb"] then
    AddAssets({
        Asset("ANIM", "anim/farm_plant_xzkb_xin_berry.zip"),
        Asset("ANIM", "anim/xzkb_xin_berry.zip"),
        Asset("ANIM", "anim/xzkb_xin_berry_cooked.zip"),
        Asset("ANIM", "anim/xzkb_xin_berry_seeds.zip"),
        Asset("ANIM", "anim/xzkb_xin_wupin_jam.zip"),
    })
    table.insert(ingredients_pl, { { "xzkb_xin_berry" }, { fruit = 1 }, true, false })
    table.insert(ingredients_pl, { { "vagteouqivwx_yus_wmquwe_xqmxrwyiy" }, { fruit = 1 }, true, false })
    -- AddSeedData("xzkb_xin_berry", RARE)
    TUNING.PASTORAL_SEEDPACKET["xzkb_xin_berry_seeds"] = 1
    -- 草莓酱
    AddRecipe2(
        "vagteouqivwx_yus_wmquwe_xqmxrwyiy",
        { Ingredient("xzkb_xin_berry", 3), Ingredient("honey", 1) }, --配方
        TECH.NONE,
        {
            numtogive = 2,
        },
        {
            "REFINE", -- 精炼分类
            "COOKING" -- 烹饪分类
        }
    )
    PLANT_DEFS.xzkb_xin_berry = {
        -- ※表示大概率要改,没有就表示大概率所有农作物都一致
        -- ※贴图与动画
        build = "farm_plant_xzkb_xin_berry",
        bank = "farm_plant_xzkb_xin_berry",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time, -- 大多数情况下都是一样的
        -- ※需水量
        moisture = moi_med,
        -- ※喜好季节
        good_seasons = { autumn = true, spring = true, summer = true },
        -- ※需肥类型
        nutrient_consumption = { nut_med, 0, nut_med },
        -- ※会生成的肥料
        nutrient_restoration = { nil, true, nil },
        -- 扫兴容忍度
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- ※重量范围
        weight_data = { 384.59, 662.77, .18 }, -- 代码加密了所以就用食趣草莓的区间吧
        -- ※音效
        sounds = PLANT_DEFS.potato.sounds,     -- 代码加密了我不知道
        -- ※作物 代码名称
        prefab = "farm_plant_xzkb_xin_berry",
        -- ※产物 代码名称
        product = "xzkb_xin_berry",
        -- ※巨型产物 代码名称
        product_oversized = "xzkb_xin_berry_oversized",
        -- ※种子 代码名称
        seed = "xzkb_xin_berry_seeds",
        -- ※家族标签
        plant_type_tag = "farm_plant_xzkb_xin_berry",
        -- ※巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "xzkb_xin_berry_seeds", "xzkb_xin_berry_seeds",
            "nightmarefuel", "nightmarefuel" },
        -- 家族化所需数量
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- ※图鉴里玩家的庆祝动作
        pictureframeanim = { anim = "emoteXL_loop_dance0", time = 7 * FRAMES }, -- 代码加密了我不知道随便用吧
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }
end

------------
--荔只只物语
------------

if not _G.SETS_PASTORAL.ENABLEDMODS["lz"] then
    AddAssets({
        Asset("ANIM", "anim/farm_plant_lz_lizhi.zip"),
        Asset("ANIM", "anim/lz_lizhi.zip")
    })
    table.insert(ingredients_pl, { { "lz_lizhi" }, { fruit = 1 }, true, false })
    -- AddSeedData("lz_lizhi", RARE)
    TUNING.PASTORAL_SEEDPACKET["lz_lizhi_seeds"] = 1
    PLANT_DEFS.lz_lizhi = {
        -- 贴图与动画
        build = "farm_plant_lz_lizhi",
        bank = "farm_plant_tomato",
        -- 生长时间
        grow_time = PLANT_DEFS.dragonfruit.grow_time,
        -- 需水量
        moisture = moi_med,
        -- 喜好季节
        good_seasons = { autumn = true, spring = true, winter = true },
        -- 需肥类型
        nutrient_consumption = { 0, 0, nut_high },
        -- 会生成的肥料
        nutrient_restoration = { true, true, nil },
        -- 扫兴容忍度
        max_killjoys_tolerance = TUNING.FARM_PLANT_KILLJOY_TOLERANCE,
        -- 是否随机种子
        is_randomseed = false,
        -- 是否防火
        fireproof = false,
        -- 重量范围
        weight_data = { 666.66, 888.88, 2.34 },
        -- 音效
        sounds = PLANT_DEFS.potato.sounds,
        -- 作物 代码名称
        prefab = "farm_plant_lz_lizhi",
        -- 产物 代码名称
        product = "lz_lizhi",
        -- 巨型产物 代码名称
        product_oversized = "lz_lizhi_oversized",
        -- 种子 代码名称
        seed = "lz_lizhi_seeds",
        -- 家族标签
        plant_type_tag = "farm_plant_lz_lizhi",
        -- 巨型产物腐烂后的收获物
        loot_oversized_rot = { "spoiled_food", "spoiled_food", "spoiled_food", "lz_lizhi_seeds",
            "fruitfly", "fruitfly" },
        -- 家族化所需数量
        family_min_count = TUNING.FARM_PLANT_SAME_FAMILY_MIN,
        -- 家族化检索距离
        family_check_dist = TUNING.FARM_PLANT_SAME_FAMILY_RADIUS,
        -- 状态的net(如果你的植物状态超过了7个阶段 换别的net)
        stage_netvar = PLANT_DEFS.pepper.stage_netvar,
        -- 界面相关(官方支持mod使用自己的界面)
        plantregistrywidget = PLANT_DEFS.pepper.plantregistrywidget,
        plantregistrysummarywidget = PLANT_DEFS.pepper.plantregistrysummarywidget,
        -- 图鉴里玩家的庆祝动作
        pictureframeanim = { anim = "emoteXL_happycheer", time = 0.5 },
        -- 生长状态(hidden 表示这个阶段不显示)
        plantregistryinfo = PLANT_DEFS.pepper.plantregistryinfo
    }
end

--------------------------------------------------------------------------
--[[ 后续相关 ]]
--------------------------------------------------------------------------

local cooking = require("cooking")
local ingredients_map = {}

for _, ing in ipairs(ingredients_pl) do
    for _, name in pairs(ing[1]) do
        ingredients_map[name] = true
    end
end

-- 因为食材配置在 AddSimPostInit 时才会加入,所以得兼容这个函数
local IsCookingIngredient_old = cooking.IsCookingIngredient
cooking.IsCookingIngredient = function(prefabname, ...)
    if ingredients_map[prefabname] then
        return true
    end
    return IsCookingIngredient_old(prefabname, ...)
end

AddSimPostInit(function()
    -- AddSimPostInit() 会在所有预制物都初始化完成后才执行,所以就不用担心官方逻辑产生相同的预制物
    for name, v in pairs(data_seeds) do -- 新增作物收获物与种子设定（只是为了种子几率,并不会主动生成prefab）
        _G.VEGGIES[name] = v
    end
    data_seeds = nil

    -- 烹饪食材属性 兼容性修改(官方逻辑没有兼容性,只能自己写个有兼容性的)
    cooking = require("cooking") -- 不确定这数据会不会同步更新,所以重新获取
    local ingredients_base = cooking.ingredients
    if ingredients_base ~= nil then
        for _, ing in ipairs(ingredients_pl) do
            for _, name in pairs(ing[1]) do
                local cancook = ing[3]
                local candry = ing[4]

                if ingredients_base[name] == nil then
                    ingredients_base[name] = { tags = {} }
                end
                if cancook then
                    if ingredients_base[name .. "_cooked"] == nil then
                        ingredients_base[name .. "_cooked"] = { tags = {} }
                    end
                end
                if candry then
                    if ingredients_base[name .. "_dried"] == nil then
                        ingredients_base[name .. "_dried"] = { tags = {} }
                    end
                end

                for tagname, tagval in pairs(ing[2]) do
                    ingredients_base[name].tags[tagname] = tagval
                    if cancook then
                        ingredients_base[name .. "_cooked"].tags.precook = 1
                        ingredients_base[name .. "_cooked"].tags[tagname] = tagval
                    end
                    if candry then
                        ingredients_base[name .. "_dried"].tags.dried = 1
                        ingredients_base[name .. "_dried"].tags[tagname] = tagval
                    end
                end
            end
        end
    end
    ingredients_pl = nil
end)

if IsServer then
    AddPrefabPostInit("daywalker", function(inst) -- 噩梦猪人有几率掉落晗猪草种子
        inst:ListenForEvent("minhealth", function(inst, data)
            if inst.components.lootdropper ~= nil then
                if math.random() < 0.5 then
                    inst.components.lootdropper:SpawnLootPrefab("piggymimosa_seeds")
                    inst.components.lootdropper:SpawnLootPrefab("piggymimosa_seeds")
                    inst.components.lootdropper:SpawnLootPrefab("piggymimosa_seeds")
                end
            end
        end)
    end)
end

-- 邪天翁羽毛可入锅
AddIngredientValues({ "malbatross_feather" }, {
    inedible = 1
})

----------------------------------------------------------
-- 种子袋容器部分
local containers = require("containers")
local params = {}

local containers_widgetsetup_base = containers.widgetsetup
function containers.widgetsetup(container, prefab, ...)
    local t = params[prefab or container.inst.prefab]
    if t ~= nil then
        for k, v in pairs(t) do
            container[k] = v
        end
        container:SetNumSlots(container.widget.slotpos ~= nil and #container.widget.slotpos or 0)
    else
        containers_widgetsetup_base(container, prefab, ...)
    end
end

local function ChangeSeedpouch()
    local container =
    {
        widget =
        {
            slotpos = {},
            animbank = "ui_chest_3x3",
            animbuild = "ui_chest_3x3",
            animbank_upgraded = "ui_chest_upgraded_3x3",
            animbuild_upgraded = "ui_chest_upgraded_3x3",
            pos = Vector3(0, 200, 0),
            unique_tag = "seedpouch",
        },
        type = "seedpouch",
        itemtestfn = function(container, item, slot)
            return item.prefab == "seeds" or string.match(item.prefab, "_seeds") or item:HasTag("treeseed")
        end,
    }

    for y = 5, 0, -1 do
        for x = 0, 5 do
            table.insert(container.widget.slotpos, Vector3(80 * x - 80 * 2.5, 80 * y - 80 * 2.5, 0))
        end
    end
    return container
end

params.seedpouch = ChangeSeedpouch()

for k, v in pairs(params) do
    containers.MAXITEMSLOTS = math.max(containers.MAXITEMSLOTS, v.widget.slotpos ~= nil and #v.widget.slotpos or 0)
end

AddClassPostConstruct("widgets/containerwidget", function(self)
    local oldOpen = self.Open
    self.Open = function(self, container, ...)
        local widget = container.replica.container:GetWidget()
        if widget.unique_tag == "seedpouch" then
            self.bganim:SetScale(2, 2, 2)
        end
        oldOpen(self, container, ...)
    end
end)

local function onopen(inst)
    inst.SoundEmitter:PlaySound("dontstarve/movement/foley/backpack")
end

local function onclose(inst)
    inst.SoundEmitter:PlaySound("dontstarve/movement/foley/backpack")
end


local function OnUpgrade(inst, performer, upgraded_from_item)
    local numupgrades = inst.components.upgradeable.numupgrades
    if numupgrades == 1 then
        -- 设置物品堆叠大小为 true
        inst._chestupgrade_stacksize = true
        -- 如果物品有容器组件
        if inst.components.container ~= nil then
            -- 关闭容器并启用无限堆叠
            inst.components.container:Close()
            inst.components.container:EnableInfiniteStackSize(true)
            -- 设置检查物品状态的函数
            inst.components.inspectable.getstatus = regular_getstatus
        end
        -- 如果是从物品升级而来,播放特效并延迟视觉更新
        if upgraded_from_item then
            local x, y, z = inst.Transform:GetWorldPosition()
            local fx = SpawnPrefab("chestupgrade_stacksize_fx")
            fx.Transform:SetPosition(x, y, z)
        end
    end
    -- 清除升级类型
    inst.components.upgradeable.upgradetype = nil
end
local function regular_OnLoad(inst, data, newents)
    if inst.components.upgradeable ~= nil and inst.components.upgradeable.numupgrades > 0 then
        OnUpgrade(inst)
    end
end
-- 当物品被拆解时触发
local function regular_OnDecontructStructure(inst, caster)
    if inst.components.upgradeable ~= nil and inst.components.upgradeable.numupgrades > 0 then
        if inst.components.lootdropper ~= nil then
            inst.components.lootdropper:SpawnLootPrefab("alterguardianhatshard")
        end
    end
    inst.components.container:DropEverything()

    inst.no_delete_on_deconstruct = nil
end
local function regular_master_postinit(inst)
    inst.scrapbook_removedeps = { "alterguardianhatshard" }

    -- 添加升级功能
    local upgradeable = inst:AddComponent("upgradeable")
    -- 设置升级类型为 “chest”
    upgradeable.upgradetype = UPGRADETYPES.CHEST
    -- 设置物品升级时的回调函数
    upgradeable:SetOnUpgradeFn(OnUpgrade)

    -- 监听物品的拆解事件
    inst:ListenForEvent("ondeconstructstructure", regular_OnDecontructStructure)

    -- 设置物品加载时的回调函数
    inst.OnLoad = regular_OnLoad
end
AddPrefabPostInit("seedpouch", function(inst)
    if not TheWorld.ismastersim then
        return inst
    end
    inst:AddComponent("lootdropper")
    inst:RemoveComponent("equippable")
    inst.components.inventoryitem.cangoincontainer = true -- 允许放入其他容器
    inst:AddTag("portablestorage")                        -- 添加便携存储标签
    -- 设置容器
    inst.components.container:WidgetSetup("seedpouch")
    inst.components.container.onopenfn = onopen
    inst.components.container.onclosefn = onclose
    inst.components.container.droponopen = true -- 打开时丢下容器
    regular_master_postinit(inst)
end)

-- 种子袋容器部分结束
----------------------------------------------------------


-- 丹木提取液
----------------------------------------------------------
AddRecipe2(
    "fruit_essence", {
        Ingredient("danmu", 2),
        Ingredient("purebrilliance", 1),
        Ingredient("lunarplant_husk", 1)
    }, TECH.SCIENCE_ONE, { numtogive = 5 },
    { "REFINE" }
)

-- 新增动作
local id = "REPAIR_FRESH"
local name = "恢复新鲜"
if not _G.SETS_PASTORAL.LANGUAGES then
    name = "Repair Fresh"
end
local fepairfreshfn = function(act)
    if act.target
        and (act.target:HasTag("fresh") or act.target:HasTag("stale") or act.target:HasTag("spoiled"))
    then
        if act.target then
            act.invobject.components.fepairfresh:ChangeFresh(act.target)
            act.doer.SoundEmitter:PlaySound("dontstarve/common/plant")
        end
        return true
    end
end
AddAction(id, name, fepairfreshfn)
ACTIONS.REPAIR_FRESH.priority = 10

local type = "USEITEM"
local component = "fepairfresh"
local fepairfreshfn_ = function(inst, doer, target, actions, right)
    if doer:HasTag("player") and inst.prefab == "fruit_essence" and target.replica.inventoryitem
        and (target:HasTag("fresh") or target:HasTag("stale") or target:HasTag("spoiled"))
    then
        table.insert(actions, ACTIONS.REPAIR_FRESH)
    end
end
AddComponentAction(type, component, fepairfreshfn_)
local state = "doshortaction"
AddStategraphActionHandler("wilson", ActionHandler(ACTIONS.REPAIR_FRESH, state))
AddStategraphActionHandler("wilson_client", ActionHandler(ACTIONS.REPAIR_FRESH, state))
-- 丹木提取液结束
----------------------------------------------------------




-- 亮茄针
AddRecipe2(
    "eggplant_avoiding_needle", {
        Ingredient("lunarplant_husk", 5),
        Ingredient("yq_bocai", 40),
        Ingredient("slurtle_shellpieces", 20)
    }, TECH.SCIENCE_TWO, {
        placer = "eggplant_avoiding_needle_placer",
        min_spacing = 1
    }, { "STRUCTURES" }
)

-- 优化写法,参考了luka的代码
AddComponentPostInit("lunarthrall_plantspawner", function(self)
    local old_FindHerd = self.FindHerd
    self.FindHerd = function(...)
        local old_plantherds = shallowcopy(self.plantherds)
        self.plantherds = {}
        for i, herd in ipairs(old_plantherds) do
            if not FindEntity(herd, 40, nil, { 'eggplant_avoiding_needle' }) then
                table.insert(self.plantherds, herd)
            end
        end
        local ret = { old_FindHerd(...) }
        self.plantherds = old_plantherds
        return unpack(ret)
    end
end)
-- 亮茄针结束

local foods = require("preparedfoods_pastoral")

-- 料理
for k, recipe in pairs(foods) do
    AddCookerRecipe("cookpot", recipe)         -- 烹饪锅
    AddCookerRecipe("archive_cookpot", recipe) -- 档案馆远古窑,有好多mod作者忽略了这口锅
    AddCookerRecipe("portablecookpot", recipe) -- 便携式烹饪锅

    if recipe.card_def then
        AddRecipeCard("cookpot", recipe) -- 食谱卡
    end
end

-- 兼容调味粉
GenerateSpicedFoods(foods)
local spicedfoods = require("spicedfoods")
for k, recipe in pairs(spicedfoods) do
    if recipe.basename and foods[recipe.basename] then
        AddCookerRecipe("portablespicer", recipe, true)
    end
end

modimport("scripts/hook_pastoral.lua") -- 在原版的代码中,加入自己的代码

if _G.SETS_PASTORAL.LANGUAGES == "english" then
    modimport("scripts/languages/strings_english.lua")
else
    modimport("scripts/languages/strings_chinese.lua")
end
